﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;

public partial class mstGeneral : MasterPage
{
    #region Functions

    protected override void OnInit(EventArgs e)
    {
        if (Session["Branding"] == null)
        {
            //  Temporary.
            //  ToDo    :   The User's Session has expired, redirect to the Login Screen.
            Response.Redirect("~/Branding/Select.aspx");
        }
        else
        {
            if (ValidUserID())
            {
                string sStylesheetURL = string.Concat("~/Branding/", Session["Branding"], "/Stylesheets/General.css");

                HtmlLink hlStylesheet = new HtmlLink();
                hlStylesheet.Href = sStylesheetURL;
                hlStylesheet.Attributes.Add("rel", "Stylesheet");
                hlStylesheet.Attributes.Add("type", "text/css");

                Page.Header.Controls.Add(hlStylesheet);
            }
            else
            {
                HttpContext.Current.Response.Redirect("~/MyAccount/Login/Login.aspx");
            }
        }
    }

    private static bool ValidUserID()
    {
        if (HttpContext.Current.Session["CurrentUserID"] == null)
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    #endregion
}